<form class="form-signin" action="/login" method="post">
    <h2 class="form-signin-heading">Login</h2>

    <div class="control-group">
        <div class="controls">
            <input name="u" id="login" value="" class="form-control" placeholder="Username" type="text">
        </div>
    </div>

    <div class="control-group">
        <div class="controls">
            <input name="p" id="password" value="" class="form-control" placeholder="Password" type="password">
        </div>
    </div>


    <div class="button-lock">
        <button id="button-lock" disabled="disabled" class="btn btn-large btn-danger btn-block">
            <span class="glyphicon glyphicon-lock"></span>Lock
        </button>
    </div>
    <div class="button-login">
        <button id="button-login" name="submit" type="submit" class="btn btn-large btn-primary btn-block">
            Login
        </button>
    </div>            
</form>
<script>
    $(document).ready(function () {
    jQuery.validator.addMethod("lettersonly", function (value, element) {
        return this.optional(element) || /^[a-z0-9_-]+$/i.test(value);
    }, "Please use only a-z0-9_-");
    $('#form-signin').validate({
        rules: {
            login: {
                minlength: 3,
                maxlength: 15,
                required: true,
                lettersonly: true
            },
            password: {
                minlength: 3,
                maxlength: 15,
                required: true,
                lettersonly: true
            },
        },
        highlight: function (element) {
            $(element).closest('.control-group').addClass('has-error');

            $("#button-lock").show();
            $("#button-login").hide();
        },
        unhighlight: function (element) {
            $(element).closest('.control-group').removeClass('has-error');

            /* Hidden button login */
            var inputlogin = document.getElementById("login").value.length;
            ;
            var inputlock = document.getElementById("password").value.length;
            ;

            if (inputlogin >= 3 && inputlock >= 3)
            {
                $("#button-lock").hide();
                $("#button-login").show();
            }
        }
    });
});

</script>